package ink.lovejinhu.leetcode;

/**
 * @author jinhu
 * created 2021-07-14 10:39
 */
public class Solution_0392 {
    /**
     * 判断子序列
     * s是否是t的子序列
     *
     * @param s
     * @param t
     * @return
     */
    public boolean isSubsequence(String s, String t) {
        char[] chars0 = s.toCharArray();
        char[] chars1 = t.toCharArray();
        int i = 0;
        int j = 0;
        for (; i < chars0.length && j < chars1.length; ) {
            if (chars0[i] == chars1[j]) {
                i++;
                j++;
            } else {
                j++;
            }
        }
        if (!(i < chars0.length)) return true;
        else return false;
    }
}
